package yt.demo.demoadmin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import yt.demo.appcommonbean.http.RestResponse;
import yt.demo.appcoresystem.dto.LoginDTO;
import yt.demo.appcoresystem.dto.MenuTreeDTO;
import yt.demo.appcoresystem.service.IAdminAuthService;
import yt.demo.appcoresystem.vo.LoginVo;
import java.util.*;

@RestController
@RequestMapping("/auth")
public class AuthController {

    IAdminAuthService service;

    @Autowired
    public AuthController(IAdminAuthService service) {
        this.service = service;
    }

    @PostMapping("/login")
    public RestResponse<LoginVo> login(@RequestBody @Validated LoginDTO dto) {
        return RestResponse.ok(this.service.login(dto));
    }

    @GetMapping("/getMenu")
    public RestResponse<List<MenuTreeDTO>> getMenu() {
        return RestResponse.ok(this.service.getMenu());
    }
}
